﻿using System;
using System.Collections.Generic;
using System.Text;
using Mind.Data;


namespace Mind.SampleProject.Data
{
   
    public class SellerSchema: Schema<SellerSchema>
    {
        private const string _TableName = "Seller";
        public const string SellerIdColumn = "SellerId";
        public const string NameColumn = "Name";

        protected override void GenerateColumns()
        {
            AddColumnInfo(ColumnInfo.CreatePrimaryKeyColumn(SellerIdColumn, typeof(int)));
            AddColumnInfo(ColumnInfo.CreateNormalColumn(NameColumn, typeof(string), false, 0));
        }

        protected override void GenerateLockups()
        {
            
        }

        protected override string GetTableName()
        {
            return _TableName;
        }
    }


    public partial class Seller : Wrapper<Seller, SellerSchema>
    {
     

        public int SellerId
        {
            get
            {
                return GetColumnValue<int>(SellerSchema.SellerIdColumn).GetValueOrDefault();
            }

            set
            {
                SetColumnValue(SellerSchema.SellerIdColumn, value);
            }
        }

        public string Name
        {
            get
            {
                return GetColumnString(SellerSchema.NameColumn);
            }

            set
            {
                SetColumnValue(SellerSchema.NameColumn, value);
            }
        }

        public void Teste()
        {
            //Select<Seller> select = new Select<Seller>().From<Seller>().Projection(SellerSchema.NameColumn, SellerSchema.PhoneCollumn).
            //    InnerJoin<SellerType>().Where(SellerSchema.NameColumn).Like("Milke").And().OpenGroup(SellerTypeSchema.SellerTypeId).IsEqualTo(1).Or(SellerSchema.PhoneCollumn).Like("51%").CloseGroup();

            //foreach (Seller seller in select.Reader())
            //{
            //    Console.WriteLine(seller.Name);
            //}
        }
    }


    
    
}
